package org.brownflat.lighthouse.web;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.integration.spring.SpringBean;
import org.brownflat.lighthouse.cache.HistoryService;
import org.brownflat.lighthouse.monitoring.ci.Build;
import org.brownflat.lighthouse.monitoring.ci.Feed;
import org.brownflat.lighthouse.monitoring.monitor.LighthouseTask;
import org.brownflat.lighthouse.monitoring.monitor.MonitoringService;

import java.util.List;

/**
 * &copy; Rupert Jones 2011
 */
public class HomeAction extends AbstractAction {

    @SpringBean
    private HistoryService historyService;

    @SpringBean
    private MonitoringService monitoringService;

    @DefaultHandler
    public Resolution view() {
        return getForwardJSPResolution("home.jsp");
    }

    public List<Build> getBuilds() {
        return historyService.get().getBuilds();
    }

    public boolean isCurrentlyBroken() {
        return historyService.get().isCurrentlyBroken();
    }

    public List<LighthouseTask> getAllTasks() {
        return monitoringService.getAllTasks();
    }
}
